/*********************
* Author:Dzlua
* QQ:505544956
* time:2016/12/09
*/
#include "LuaFont.h"
#include "../edui.h"

#ifdef EDUI_USE_LUAPLUS

EDUI_NAMESPACE_BEGIN

#ifdef EDUI_TEST_NEW_DELETE
int LuaFont::m_newdeleteNum = 0;
int LuaFont::_GetNewDeleteNum()
{
    return m_newdeleteNum;
}
#endif

void* LuaFont::GetInterface(void* data)
{
    if (!data) return 0;
    LuaFont* font = new LuaFont((IFont*)data);
#ifdef EDUI_TEST_NEW_DELETE
    ++m_newdeleteNum;
    Log("[LuaFont] new LuaFont : %d, %d", font, data);
#endif
    return font;
}

void LuaFont::Release()
{
#ifdef EDUI_TEST_NEW_DELETE
    --m_newdeleteNum;
    Log("[LuaFont] delete LuaFont : %d, %d", this, m_cobj);
#endif
    delete this;
}

void* LuaFont::GetCObj()
{
    return m_cobj;
}

LuaFont::LuaFont(IFont* font)
{
    m_cobj = font;
}

LuaFont::~LuaFont()
{}

//----------------------------------------//

//----------------------------------------//

void LuaFont::Register(LuaState *L)
{
    LuaObject obj = LuaHelperNS::AddToMetas(L, "Font");
    obj.SetObject("__index", obj);
    obj.RegisterDirect("__NewCObj__", &LuaFont::GetInterface);
    
}

EDUI_NAMESPACE_END

#endif